/**
 *	\file
 *	\brief represents a resource defined in a function.
 *
 *	A resource defined in a function can  be:
 *	\li a local variavble;
 *	\li a formal parameter;
 *
 *	If the local resource is
 *
 * 	\date Aug 31, 2013
 * 	\author koldar
 */

#ifndef LOCALRESOURCEELEMENT_H_
#define LOCALRESOURCEELEMENT_H_

#include "PassMode.h"
#include "schema.h"

#define _LOCALRESOURCELEMENT_RETURNNAME_ '\0'

/**Represents a single local Resource that should be stored in the Local Environment
 *
 */
typedef struct LocalResourceElement {
	char* name; //!< indicates the name of the local resource. '\0' if the resource is the return value
	Pschema schema; //!< indicates the type of the local resource. NULL if the type is "void"
	PassMode mode; //!< indicates the pass mode of this resource. Ignored if the local resource is a local variable
} LocalResourceElement;

/**points to a LocalResourceElement
 *
 */
typedef LocalResourceElement* PlocalResourceElement;
/**points to a local resource of a function. This alias has been
 * created to improve readability if you want to interpret a pointer
 * to this structure not like a single reference, but like a list.
 */
typedef LocalResourceElement* LocalResourceList;

/**creates a new instance of a LocalResourceElement
 *
 * \pre
 *  \li _name must be not NULL;
 *  \li schema must be not NULL;
 * \post
 *  \li a new LocalResourceElement is allocate in memory. Must be freed using freeLocalResourceElement()
 *
 * @param _name the name of this resource
 * @param schema the type of this resource.
 * @param _passmode the pass mode of this resource
 * @return a pointer to a LocalResourceElement
 */
PlocalResourceElement initLocalResourceElement(char* _name,Pschema schema,PassMode _passmode);

/**free a local resource previously allocated with initLocalResourceElement()
 *
 * \pre
 *  \li obj not NULL
 * \post
 *  \li obj is correctly freed from the memory
 *
 * @param obj the obj to be freed
 */
void freeLocalResourceElement(PlocalResourceElement obj);

/**prints a string representation of this local resource
 *
 * \pre
 *  \li f open in write mode
 *  \li obj not NULL
 * \post
 *  \li f changes
 *
 * @param f the file to write on the resource
 * @param obj the resource to be printed
 */
void printLocalResourceElement(FILE* f,PlocalResourceElement obj);

//TODO documentation
void generateDOTLocalResourceElement(FILE* f,PlocalResourceElement obj,int* startnode,int* cellnumber,int format);

#endif /* LOCALRESOURCEELEMENT_H_ */
